<template>
  <CesiumBox ref="container"></CesiumBox>
</template>

<script setup>
import CesiumBox from "../../components/CesiumBox.vue";
import { ref, onMounted } from "vue";
import * as Cesium from "cesium";

const container = ref(null);
let cesiumPara = null;

function addBuild() {
  let tileset = cesiumPara.viewer.scene.primitives.add(
    new Cesium.Cesium3DTileset({
      url: process.env.VUE_APP_TOMCAT + "/cesium/build/tileset.json",
    })
  );

  tileset.style = new Cesium.Cesium3DTileStyle({
    color: {
      conditions: [["true", "color('purple', 0.8)"]],
    },
  });
}

onMounted(() => {
  cesiumPara = container.value.cesiumPara;
  addBuild();

  cesiumPara.viewer.camera.flyTo({
    destination: Cesium.Cartesian3.fromDegrees(
      125.29205010375024,
      43.846426460858815,
      931.3050623720223
    ),
    orientation: {
      heading: 0.05956398801633167,
      pitch: -0.43653091585028125,
      roll: 0.000011909843509627649,
    },
    duration: 3,
  });
});
</script>
